<?php


#$indent = mysql_connect(SERVER_DB, USER_DB, PASS_DB)or die (mysql_error());
#DBConnect::query("set names utf8");
#mysql_select_db(DB, $indent) or die (mysql_error());


class Connect #extends DBConnect 
{
    
    #public $db;
    
    /*function __construct(){
        parent::__construct(SERVER_DB, USER_DB, PASS_DB, DB, PREFIX_STATIC);
        #$this->db = new DBConnect(SERVER_DB, USER_DB, PASS_DB, DB, PREFIX_STATIC);
    }*/
    
    public static $__error;
    public static $success = true;
    public static  $Message = 1;
    public static  $Sistem = 0;
    var $log ;
    var $logfile = "logs/log.log";
    #public static $errorText = "";
    
    static function _error($error = false, $code = 0){
        Connect::$success = false;
        if($error && $error == mysql_error()){
            if(DEBUG != false){
                Connect::$__error = array('error' => $error, 'code' => $code); 
            }else{
                Connect::$__error = array('error' => "Ошибка сервера", 'code' => $code);
            }
        }else{
            Connect::$__error = array('error' => $error, 'code' => $code);    
        }
    }
    
    static function complete($data = false, $message = false){
        $arr = array();
        $arr['success'] = true;
        if($message)$arr['message'] = $message;
        #if($data)
        $arr['data'] = @$data;
        
        return $arr;
    }
    
    static function error($error = false, $data = false){
        $arr = array();
        $arr['success'] = false;
        if($error)$arr['error'] = $error;
        if($data)$arr['data'] = $data;
        
        return $arr;
    }
    
    function logStart($query){
        if(!$this->log) $this->log =  new log(CORE_PATH.$this->logfile);
        $this->log->start($query);
    }
    
    function logEnd(){
        #if(!$this->log) $this->log =  new log($this->logfile);
        $this->log->end();
    }
    
    
    
}


?>